$(function()
 {
	$('#username').button();
	$('#password').button();
	$('#login').button();
	
 });

function doLogin()
 {
	 var username = $('#username').val();
	 var password = $('#password').val();
	 
	 $.get('checkuser.php',
	 {
		 'username': username,
		 'password': password
	 },function(data)
	 {
		 if(data ==0)
		 {
			 event.preventDefault();
					$('#dialogLogin').html('Fail Login')

					$('#dialogLogin').dialog({
						'title':'Error',
						draggable: false
						});
					$( "#dialogLogin" ).dialog({ buttons: [ { text: "Ok", click: function() { $( this ).dialog( "close" ); } } ] });
					
		 }
		 else if(data ==1)
		 {
			// alert('OK!');
			$.get('addbook.html',function(data)
			 {
				$('#mainContent').html(data);
				getData();
			 });
		 }
		 else
		 {
			 alert(data);
		 }
	 });
 }